<template>
    <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                    <a-col :span="6" :sm="6">
                        <a-form-item label="复审分组">
                            <a-select v-model="cxj_fs_fz_id" placeholder="请选择初审分组" @change="handleSelectFz">
                                <a-select-option v-for="item in xszjfzData" :key="item.id" :value="item.cxj_fs_fz_id">
                                    {{item.fs_fz_mc}}
                                </a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col :span="6" :sm="6">
                        <a-form-item label="答辩时间">
                            <a-select v-model="dbsj" placeholder="请选择答辩时间" @change="handleTime">
                                <a-select-option v-for="(item,index) in cxjfsDbsjlist" :key="index" :value="item.id">
                                    {{item.fs_sj_rq}}{{item.fs_sj_sxw}}
                                </a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col :span="12" :sm="12">
                        <div class="tjdata">
                            <span>总数量：<span class="count">{{reviewStatistics.sum}}</span></span>
                            <span>已评分：<span class="count">{{reviewStatistics.ypf}}</span></span>
                            <!-- <span>暂存：</span> -->
                            <span>未评分：<span class="count">{{reviewStatistics.wpf}}</span></span>
                            <span>评分状态: <span class="count">{{reviewStatistics.pfzt==0?'未提交':reviewStatistics.pfzt==1?'已提交': ''}}</span></span>
                            <a-button type="primary" style="margin: 0px;" :disabled="reviewStatistics.pfzt==0?false:reviewStatistics.pfzt==1?true:''" @click="submitQrode(reviewStatistics)">签名并提交</a-button>
                            <a-button type="primary" style="margin: 0px 0 0 10px;" :disabled="reviewStatistics.pfzt==0" @click="ratingPreview(1)">评分预览</a-button>
                        </div>
                    </a-col>
                    <!-- <a-col :span="6" :sm="6">
                        <a-button type="primary" style="margin: 0px;" :disabled="reviewStatistics.pfzt==0?false:reviewStatistics.pfzt==1?true:''" @click="submitAll(reviewStatistics)">全部提交</a-button>
                    </a-col> -->
                </a-row>
            </a-form>
          <p style="color: #ff0000;font-size: 16px;">该组成果全部评审完成后，点击"全部提交"完成评分，提交后不可修改。</p>
        </div>
        <!-- 查询区域-END -->
        <!-- 操作按钮区域 高级查询区域-->
        <div class="table-operator" style="display: flex; align-items: center;justify-content: space-between;"></div>
        <!-- table区域-begin -->
        <div>
            <h2 style="text-align:center;font-size: 20px;">
                {{new Date().getFullYear()}}年度电力创新奖成果复审意见表(标准类)
                <!-- <a-button type="primary" style="margin: 0px;" @click="downloadFile">初审表下载</a-button> -->
            </h2>
            <!-- tableLayout="auto" -->
            <a-table
                ref="table"
                size="middle"
                :scroll="{x: 1100}"
                bordered
                rowKey="cxj_xmbh"
                :columns="columns"
                :dataSource="dataSource"
                :pagination="ipagination"
                :loading="loading"
                class="j-table-force-nowrap"
                @change="handleTableChange">
                <!--
                    v-for="col in ['fs_xmcs','fs_zjtw','fs_cx', 'fs_js', 'fs_xj', 'fs_jj', 'fs_sh','fs_cj','fs_ts','fs_zs','fs_hj']"
                 -->
                <template
                    v-for="col in ['fs_xmcs','fs_zjtw','fs_cx', 'fs_js', 'fs_xj', 'fs_jj', 'fs_sh','fs_cj','fs_ts','fs_zs']"
                    :slot="col"
                    slot-scope="text, record"
                >
                    <div :key="col">
                        <a-popover placement="top" v-if="record.editable">
                            <template slot="content">
                                <!-- 项目陈述 -->
                                <div v-if="col=='fs_xmcs'">
                                    <p>前三完成人答辩，材料准备充分，陈述十分流畅，语言简练，论证严谨，3分</p>
                                    <p>材料准备基本充分，陈建本清晰，1-2分</p>
                                    <p>仅能完成项目陈述，表迖充畅程度一般，0分</p>
                                </div>
                                <!-- 专家提问及应答 -->
                                <div v-else-if="col=='fs_zjtw'">
                                    <p>能有效、正确、全面解答提问，表述清晰，论证严谨，2分</p>
                                    <p>基本能正确回答提问，表述基本清晰，1分</p>
                                    <p>仅能回答部分提问，0分</p>
                                </div>
                                <!-- 创新程度 -->
                                <div v-else-if="col=='fs_cx'">
                                    <p>有重大创新，创新性突出，11-15分</p>
                                    <p>有较大创新，创新性明显，6-10分</p>
                                    <p>有一定创新，创新性比较明显，1-5分</p>
                                </div>
                                <!-- 技术水平 -->
                                <div v-else-if="col=='fs_js'">
                                    <p>技术难度大，16-20分</p>
                                    <p>技术难度较大，10-15分</p>
                                    <p>有一定技术难度，1-9分</p>
                                </div>
                                <!-- 先进水平 -->
                                <div v-else-if="col=='fs_xj'">
                                    <p>达到或接近国际先进水平，11-15分</p>
                                    <p>达到国际水平，6-10分</p>
                                    <p>达到国内先进水平，1-5分</p>
                                </div>
                                <!-- 经济效益 -->
                                <div v-else-if="col=='fs_jj'">
                                    <p>效益重大，16-20分</p>
                                    <p>效益显著，10-15分</p>
                                    <p>有较大收益，1-9分</p>
                                </div>
                                <!-- 社会效益 -->
                                <div v-else-if="col=='fs_sh'">
                                    <p>效益重大，8-10分</p>
                                    <p>效益显著，5-7分</p>
                                    <p>有较大收益，1-4分</p>
                                </div>
                                <!-- 促进行业经济发展情况 -->
                                <div v-else-if="col=='fs_cj'">
                                    <p>有促进作用，3-5分</p>
                                    <p>有一定促进作用，1-2分</p>
                                </div>
                                <!-- 提升管理水平情况 -->
                                <div v-else-if="col=='fs_ts'">
                                    <p>有提升作用，3-5分</p>
                                    <p>有一定提升作用，1-2分</p>
                                </div>
                                <!-- 知识产权 -->
                                <div v-else-if="col=='fs_zs'">
                                    <p>具有知识产权的，3-5分</p>
                                    <p>正在申请知识产权的，1-2分</p>
                                    <p>无任何知识产权的，0分</p>
                                </div>
                                <!-- 获奖情况 -->
                                <!-- <div v-else-if="col=='fs_hj'">
                                    <p>有多项获奖情况的，3-5分</p>
                                    <p>有获奖情况的，1-2分</p>
                                </div> -->
                            </template>
                            <a-input
                                type="number"
                                style="margin: -5px 0"
                                :value="text"
                                @change="e => handleChange(e.target.value, record.key, col)"
                            />
                        </a-popover>
                        <template v-else>
                            {{ text }}
                        </template>
                    </div>
                </template>
                <template slot="fs_pingshenyj" slot-scope="text, record">
                    <div key="fs_pingshenyj">
                        <a-textarea
                            :value="text"
                            v-if="record.editable"
                            placeholder="请填写评审意见"
                            @change="e => handleChange(e.target.value, record.key, 'fs_pingshenyj')"
                            @click="e => handleOpinion(e.target.value, record.key, record.cxj_cxj_id, 'fs_pingshenyj')"
                            :auto-size="{ minRows: 1, maxRows: 5 }"
                        />
                        <template v-else>
<!--                            {{ text }}-->
                            <a-popover title="" placement="bottom" arrow-point-at-center>
                                <template slot="content">
                                    <p style="max-width:300px;word-break: break-all;">{{ text }}</p>
                                </template>
                                <span class="sl-span">{{ text }}</span>
                            </a-popover>
                        </template>
                    </div>
                </template>
                <template slot="fs_sfhb" slot-scope="text, record">
                    <div key="fs_sfhb">
                        <a-radio-group default-value="N" v-model="record.fs_sfhb" v-if="record.sfzs && record.sfzs=='主审'">
                            <a-radio value="Y" disabled>是</a-radio>
                            <a-radio value="N" disabled>否</a-radio>
                        </a-radio-group>
                        <a-radio-group default-value="N" v-model="record.fs_sfhb" v-else>
                            <a-radio value="Y" :disabled="!record.editable">是</a-radio>
                            <a-radio value="N" :disabled="!record.editable">否</a-radio>
                        </a-radio-group>
                    </div>
                </template>
                <span slot="cxj_xmbh" slot-scope="text, record">
                    <span>{{record.cxj_xmbh}}</span>
                    <span v-if="record.sfzs" style="color:#ff0000;font-weight:bold;">({{record.sfzs}})</span>
                    <span v-else style="color:#ff0000;font-weight:bold;">{{record.sfzs}}</span>
                </span>
                <span slot="cgzlAction" slot-scope="text, record">
                    <a @click="handlePreview(record)">查看</a>
                </span>
                <span slot="fs_zongfen" slot-scope="text, record">
                    <span>{{record.fs_zongfen}}</span>
                </span>
                <template slot="action" slot-scope="text, record">
                    <div class="editable-row-operations">
                        <span v-if="!record.editable">
                            <a v-if="record.fs_zhuangtai==1" disabled>评分</a>
                            <a v-else :disabled="editingKey !== ''?true:false" @click="() => edit(record.key)">评分</a>
                        </span>
                        <!-- <a-divider type="vertical" /> -->
                        <span v-else>
                            <a @click="() => save(record.key, record)">保存</a>
                            <a-popconfirm title="真的放弃编辑吗?" @confirm="() => cancel(record.key)">
                                <a>取消</a>
                            </a-popconfirm>
                        </span>
                    </div>
                </template>
            </a-table>
        </div>
        <cxj-jscs-pf-js-modal ref="modalForm" @ok="modalFormOk"></cxj-jscs-pf-js-modal>
        <!-- 二维码 -->
        <a-modal
            :visible="qrcodeVisible"
            @cancel="handleCancel()"
            title="请用手机扫二维码签名"
            centered
            :footer="null"
            width="400px"
            height="400px"
        >
            <vue-qr :text="imgQrUrl" :size="360" :margin="0"></vue-qr>
        </a-modal>
        <!-- pdf -->
        <view-pdf :params="pafParams" :showPdf="showpdf" @reset="getQrUrl" @sure="handleSure" :pafBtn="pafBtn" path="cxjFsPfJs"></view-pdf>
        <OpinionModal :showFlag="opinionFlag" :opinion="opinionValue" @updateOpinion="updateOpinion"/>
    </a-card>
</template>

<script>
import VueQr from 'vue-qr'
import viewPdf from '@/views/cxj/viewPdf'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CxjJscsPfJsModal from './modules/CxjJscsPfJsModal'
import { getAction,postAction } from '../../api/manage'
import qs from 'qs';
import Vue from 'vue'
import { USER_INFO, ACCESS_TOKEN } from "@/store/mutation-types"
import {
    // 复审项目评分表-标准类-查询二维码状态接口
    cxjfsCheckQrcode,
    // 复审项目评分表-标准类-查询二维码
    cxjfsSubmitQrcode,
    // 复审分组专家表-获取分组列表
    cxjFsGetZjFz,
    // 复审项目评分表-标准类-获取分组项目
    cxjfsGetFzxmListByFzidBz,
    // 复审项目评分表-标准类-评分保存或修改
    cxjfsSavePfBzBz,
    // 标准复审评分表-评分统计-专家
    fsPfTjZjBz,
    // 复审项目评分表-标准类-评分提交
    cxjfsSubmitPfBzBz
} from  "@/api/api";
import moment from 'moment';
import {
    // 技术初审评分表-导出
    jscsPfExport
} from "@/api/manage"
import OpinionModal from './OpinionModal/index.vue'
export default {
    name: 'CxjJscsPfJsList',
    // mixins:[JeecgListMixin, mixinDevice],
    mixins:[mixinDevice],
    components: {
        CxjJscsPfJsModal,
        VueQr,
        viewPdf,
        OpinionModal
    },
    data () {
        // this.cacheData = dataSource.map(item => ({ ...item }));
        return {
            opinionFlag: false,
            opinionKey: '',
            opinionValue: '',



            pdfFilePath: '',
            showpdf: false,
            pafBtn: false,
            pafParams: {},
            qrcodeVisible: false,
            imgQrUrl: '',
            cxjfsDbsjlist: [],
            dbsj: '',
            xszjfzData: [],
            cxj_fs_fz_id: '',
            reviewStatistics: '',
            cacheData: [],
            description: '初审项目评分表-技术类-获取分组项目',
            // 表头
            columns: [
                /**
                 * 成果陈述 3分 fs_xmcs
                 * 专家提问及应答 2分 fs_zjtw
                 * 创新程度 15分 fs_cx
                 * 技术水平 20分 fs_js
                 * 先进水平 15分 fs_xj
                 * 经济效益 18分 fs_jj
                 * 社会效益 9分 fs_sh
                 * 促进行业经济发展 4分 fs_cj
                 * 提升管理水平 4分 fs_ts
                 * 知识产权 5分 fs_zs
                 * 获奖情况 5分 fs_hj
                */
                {
                    title: '答辩序号',
                    dataIndex: 'xm_xh',
                    key: 'rowIndex',
                    width: '5%',
                    customCell: () => {
                        return {
                            style: {
                                'min-width': '40px',
                            },
                        };
                    },
                    align:"center",
                    // fixed: 'left',
                    // customRender:function (t,r,index) {
                    //     return parseInt(index)+1;
                    // }
                },
                {
                    title: '成果编号',
                    align: "center",
                    dataIndex: 'cxj_xmbh',
                    width: '12%',
                    scopedSlots: { customRender: 'cxj_xmbh' },
                    customCell: () => {
                        return {
                            style: {
                                'min-width': '80px',
                            },
                        };
                    },
                },
                {
                    title: '成果名称',
                    dataIndex: 'cxj_mc_zw',
                    width: '15%',
                    customCell: () => {
                        return {
                            style: {
                                'min-width': '130px',
                            },
                        };
                    },
                },
                {
                    title: '成果资料',
                    align: "center",
                    dataIndex: 'cgzlAction',
                    width: '5%',
                    customCell: () => {
                        return {
                            style: {
                                'min-width': '80px',
                            },
                        };
                    },
                    scopedSlots: { customRender: 'cgzlAction' }
                },
                {
                    title: '审查意见',
                    // width: 800,
                    align: 'center',
                    children: [
                        {
                            title: '成果陈述',
                            align: "center",
                            width: '5%',
                            customCell: () => {
                                return {
                                    style: {
                                        'min-width': '100px',
                                    },
                                };
                            },
                            children: [{
                                title: "3分",
                                align:"center",
                                width: '5%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_xmcs",
                                scopedSlots: { customRender: 'fs_xmcs' }
                            }]
                        },
                        {
                            title: '专家提问及应答',
                            align: "center",
                            width: '5%',
                            customCell: () => {
                                return {
                                    style: {
                                        'min-width': '100px',
                                    },
                                };
                            },
                            children: [{
                                title: "2分",
                                align:"center",
                                width: '5%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_zjtw",
                                scopedSlots: { customRender: 'fs_zjtw' }
                            }]
                        },
                        {
                            // title: '创新程度、技术水平、先进水平(50分)',
                            title: '创新程度(50分)',
                            align: "center",
                            width: '18%',
                            customCell: () => {
                                return {
                                    style: {
                                        'min-width': '100px',
                                    },
                                };
                            },
                            children: [{
                                // title: "创新程度(15分)",
                                title: '创新类型（15分）',
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_cx",
                                scopedSlots: { customRender: 'fs_cx' }
                            },{
                                // title: "技术水平(20分)",
                                title: '技术水平（20分）',
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_js",
                                scopedSlots: { customRender: 'fs_js' }
                            },{
                                // title: "先进水平(15分)",
                                title: '先进水平（15分）',
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_xj",
                                scopedSlots: { customRender: 'fs_xj' }
                            }]
                        },
                        {
                            title: '经济效益和社会效益(30分)',
                            align: "center",
                            width: '12%',
                            customCell: () => {
                                return {
                                    style: {
                                        'min-width': '100px',
                                    },
                                };
                            },
                            children: [{
                                title: "经济效益（20分）",
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_jj",
                                scopedSlots: { customRender: 'fs_jj' }
                            },{
                                title: "社会效益(10分)",
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_sh",
                                scopedSlots: { customRender: 'fs_sh' }
                            }]
                        },
                        {
                            title: '对行业经济和发展的促进作用(10分)',
                            align: "center",
                            width: '12%',
                            customCell: () => {
                                return {
                                    style: {
                                        'min-width': '100px',
                                    },
                                };
                            },
                            children: [{
                                title: "促进行业经济发展情况(5分)",
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_cj",
                                scopedSlots: { customRender: 'fs_cj' }
                            },{
                                title: "提升管理水平情况(5分)",
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_ts",
                                scopedSlots: { customRender: 'fs_ts' }
                            }]
                        },
                        {
                            title: '知识产权',
                            align: "center",
                            width: '6%',
                            customCell: () => {
                                return {
                                    style: {
                                        'min-width': '100px',
                                    },
                                };
                            },
                            children: [{
                                title: "是否有知识产权(5分)",
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_zs",
                                scopedSlots: { customRender: 'fs_zs' }
                            }]
                        },
                        /* {
                            title: '获奖情况',
                            align: "center",
                            width: '6%',
                            customCell: () => {
                                return {
                                    style: {
                                        'min-width': '100px',
                                    },
                                };
                            },
                            children: [{
                                title: "5分",
                                align:"center",
                                width: '6%',
                                customCell: () => {
                                    return {
                                        style: {
                                            'min-width': '100px',
                                        },
                                    };
                                },
                                dataIndex: "fs_hj",
                                scopedSlots: { customRender: 'fs_hj' }
                            }]
                        }, */
                        {
                            title: '合计',
                            align: "center",
                            width: '6%',
                            customCell: () => {
                                return {
                                    style: {
                                        'min-width': '60px',
                                    },
                                };
                            },
                            dataIndex: 'fs_zongfen',
                            scopedSlots: { customRender: 'fs_zongfen' },
                            sorter: (a, b) => b.total_score - a.total_score,
                        },
                        {
                            title: '评审意见',
                            dataIndex: 'fs_pingshenyj',
                            width: '10%',
                            scopedSlots: { customRender: 'fs_pingshenyj' }
                        },
                        {
                            title: '是否回避',
                            dataIndex: 'fs_sfhb',
                            width: '6%',
                            scopedSlots: { customRender: 'fs_sfhb' }
                        }
                    ]
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    align: "center",
                    fixed: "right",
                    width: 110,
                    scopedSlots: { customRender: 'action' }
                }
            ],
            url: {
                list: "/cxj/cxjJscsPfJs/list",
                delete: "/cxj/cxjJscsPfJs/delete",
                deleteBatch: "/cxj/cxjJscsPfJs/deleteBatch",
                exportXlsUrl: "/cxj/cxjJscsPfJs/exportXls",
                importExcelUrl: "cxj/cxjJscsPfJs/importExcel",
                // 答辩时间列表
                cxjfs_dbsjlist: '/cxj/cxjFsSj/cxjfs_getDbsjListByFzid'
            },
            superFieldList:[],
            // 分组id
            fzid: "",
            editingKey: '',


            queryParam: {},
            dictOptions:{},
            //superFieldList:[],
            fileStatus: "",
            selectedRowKeys: [],
            selectionRows: [],
            loading: false,
            isorter: {
                column: 'createTime',
                order: 'desc',
            },
            dataSource: [],
            ipagination: {
                current: 1,
                pageSize: 20,
                pageSizeOptions: ['20', '50', '100'],
                showTotal: (total, range) => {
                return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                showQuickJumper: true,
                showSizeChanger: true,
                total: 0
            },


        }
    },
    created() {
        this.$set(this.dictOptions, 'isValid', [{text:'是',value:'Y'},{text:'否',value:'N'}])
        this.getSuperFieldList();
        this.fetchCxFsGetZjFz();

    },
    watch: {
        dataSource(){
            this.updateDataSource();
        }
    },
    methods: {
        moment,
        handleOpinion(value, key, id, column) {
            this.opinionKey = id
            this.opinionValue = value
            this.opinionFlag = !this.opinionFlag
        },
        updateOpinion(value) {
            this.opinionFlag = !this.opinionFlag
            this.dataSource.forEach(item=>{
                if(item.cxj_cxj_id == this.opinionKey) {
                    item.fs_pingshenyj = value
                }
            })
        },
        handleSure() {
            let user = Vue.ls.get(USER_INFO);
            let formData = new FormData();
            formData.append('fzid', this.fzid)
            formData.append('zjid', user.id)
            const that = this

            cxjfsSubmitPfBzBz(formData).then(res=>{
                // console.log('--------',res)
                if (res.code == 200) {
                    // 签名成功后获取评分状态，保证未提交变成已提交
                    this.getjsfsPfTjZj()
                    that.$message.success(res.message);
                    that.fetchCxFsGetZjFz();
                } else {
                    that.$message.warning(res.message);
                    that.fetchCxFsGetZjFz();
                }
            })
        },
        handleCancel() {
            clearInterval(this.qrTimer)
            this.qrcodeVisible = false;
        },
        // 评分预览
        ratingPreview(flag) {
            this.pafBtn = flag == 1 ? false : true
            let user = Vue.ls.get(USER_INFO);
            this.pafParams = {
                fzid: this.fzid,
                zjid: user.id
            }
            this.showpdf = !this.showpdf
        },
        // 查询签名状态
        checkSignStatus(params) {
            clearInterval(this.qrTimer)
            this.qrTimer = setInterval(() => {
                cxjfsCheckQrcode(params,'cxjFsPfBz').then(res=>{
                    if (res.result) {
                        clearInterval(this.qrTimer)
                        this.qrcodeVisible = false
                        setTimeout(() => {
                            this.ratingPreview(2)
                        }, 3000)
                        this.$message.success("签名成功！")
                    }
                }).catch(err => {
                    this.$message.error("查询签名状态失败！")
                })
            }, 2000)
        },
        submitQrode(record) {
            if(record.ypf == record.sum){
                this.getQrUrl()
            } else {
                this.$message.warning("还未完成评分，无法提交！")
            }
        },
        // 查询二维码地址
        getQrUrl() {
            let user = Vue.ls.get(USER_INFO);
            let that = this
            let formData = new FormData();
            formData.append('fzid', this.fzid)
            formData.append('zjid', user.id)
            cxjfsSubmitQrcode(formData,'cxjFsPfBz').then(res=>{
                if (res.code === 200) {
                    this.imgQrUrl = `${window.location.origin}${res.result}&path=cxjFsPfBz`
                    this.qrcodeVisible = true
                    this.checkSignStatus({
                        fzid: that.fzid,
                        zjid: user.id
                    })
                } else {
                    this.$message.error(res.message)
                }
            }).catch(err => {
                this.$message.error("查询二维码失败！")
            })
        },
        // 获取答辩时间列表
        getDbTimeList(){
            postAction(this.url.cxjfs_dbsjlist, qs.stringify({fzid:this.fzid})).then((res) => {
                if (res.success) {
                    this.cxjfsDbsjlist = res.result.records || res.result;
                    this.cxjfsDbsjlist.unshift({
                        fs_sj_rq:"全部",
                    })
                }
                if (res.code === 510) {
                    this.$message.warning(res.message)
                }
            })
        },
        // 获取分组列表【用于技术类-获取分组项目列表参数fzid】
        fetchCxFsGetZjFz(){
            let user = Vue.ls.get(USER_INFO);
            cxjFsGetZjFz({sysZjId: user.id, flbh: 31}).then(res=>{
                if(res.success) {
                    if (res.result.length) {
                        this.xszjfzData = res.result;
                        this.fzid = res.result[0].cxj_fs_fz_id;
                        this.cxj_fs_fz_id = res.result[0].cxj_fs_fz_id;
                    }
                    this.getDbTimeList();
                    this.loadData();
                    this.getjsfsPfTjZj();
                }
            })
        },
        updateDataSource(){
            this.dataSource.map(item=>{
                // item.fs_zongfen = Number(item.fs_xmcs)+Number(item.fs_zjtw)+Number(item.fs_cx)+Number(item.fs_js)+Number(item.fs_xj)+Number(item.fs_jj)+Number(item.fs_sh)+Number(item.fs_cj)+Number(item.fs_ts)+Number(item.fs_zs)+Number(item.fs_hj);
                item.fs_zongfen = Number(item.fs_xmcs)+Number(item.fs_zjtw)+Number(item.fs_cx)+Number(item.fs_js)+Number(item.fs_xj)+Number(item.fs_jj)+Number(item.fs_sh)+Number(item.fs_cj)+Number(item.fs_ts)+Number(item.fs_zs);
            })
        },
        // 切换分组
        handleSelectFz(value){
            this.fzid = value;
            // this.getjsfsPfTjZj();
            this.loadData(1);
        },
        // 切换答辩时间
        handleTime(value){
            this.fetchCxFsGetZjFz();
        },
        // 获取技术初审评分表-评分统计
        getjsfsPfTjZj(){
            let formData = new FormData();
            formData.append('fzid', this.fzid)
            fsPfTjZjBz(formData).then(res=>{
                // console.log('获取技术初审评分表-评分统计',res)
                if(res.code == 200) {
                    this.reviewStatistics = res.result;
                } else {
                    this.$message.warning(res.message)
                }
            })
        },
        // 全部提交
        // submitAll(record){
        //     // console.log(record)
        //     let that = this;
        //     if(record.ypf == record.sum){
        //         let user = Vue.ls.get(USER_INFO);
        //         let formData = new FormData();
        //         formData.append('fzid', this.fzid)
        //         formData.append('zjid', user.id)
        //         this.$confirm({
        //             title: '确定要全部提交吗?',
        //             okText: '确定',
        //             cancelText: '取消',
        //             onOk() {
        //                 cxjfsSubmitPfBzBz(formData).then(res=>{
        //                     // console.log('--------',res)
        //                     if (res.code == 200) {
        //                         that.$message.success(res.message);
        //                         that.fetchCxFsGetZjFz();
        //                     } else {
        //                         that.$message.warning(res.message);
        //                         that.fetchCxFsGetZjFz();
        //                     }
        //                 })
        //             },
        //             onCancel() {
        //                 // console.log('Cancel');
        //             },
        //         });
        //     } else {
        //         this.$message.warning("还未完成评分，无法提交！")
        //     }
        // },
        resetSearchForm () {
            this.fetchCxFsGetZjFz();
        },
        // 初审表下载
        // downloadFile(){
        //     console.log('初审表下载')
        //     let data = {
        //         fzid: this.cxj_fs_fz_id
        //     }
        //     jscsPfExport(data).then(res=>{
        //         this.downfn('初审表下载',res);
        //     })
        // },
        downfn(name, res) {
            const _res = res;
            let blob = new Blob([_res], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
            let downloadElement = document.createElement("a");
            let href = window.URL.createObjectURL(blob); //创建下载的链接
            downloadElement.href = href;
            downloadElement.download = name; //下载后文件名
            document.body.appendChild(downloadElement);
            downloadElement.click(); //点击下载
            document.body.removeChild(downloadElement); //下载完成移除元素
            window.URL.revokeObjectURL(href); //释放掉blob对象
        },
        // 查看
        handlePreview(record){
            // console.log('查看', record.cxj_cxj_id)
            let token = Vue.ls.get(ACCESS_TOKEN);
            sessionStorage.setItem('token', token);
            let routeData = this.$router.resolve({
                path: '/shenbao/declare',
                query: {
                    type: record.fl_id,
                    cxj_cxj_id: record.cxj_cxj_id,
                    isHead: 2,
                    from: 'zj',
                    xmztbh: record.xmztbh,
                    cxj_xmbh: record.cxj_xmbh,
                    cxj_mc_zw: record.cxj_mc_zw
                }
            });
            window.open(routeData.href, '_blank');
        },

        /* 对行内进行修改开始 */
        handleChange(value, key, column) {
            const newData = [...this.dataSource];
            const target = newData.filter(item => key === item.key)[0];
            // console.log('target',target)
            if (column == 'fs_xmcs' && value > 3) {
                value = 3;
            } else if (column == 'fs_zjtw' && value > 2) {
                value = 2;
            } else if (column == 'fs_cx' && value > 15) {
                value = 15;
            } else if (column == 'fs_js' && value > 20) {
                value = 20;
            } else if (column == 'fs_xj' && value > 15) {
                value = 15;
            } else if (column == 'fs_jj' && value > 20) {
                value = 20;
            } else if (column == 'fs_sh' && value > 10) {
                value = 10;
            } else if (column == 'fs_cj' && value > 5) {
                value = 5;
            } else if (column == 'fs_ts' && value > 5) {
                value = 5;
            } else if (column == 'fs_zs' && value > 5) {
                value = 5;
            }
            /* else if (column == 'fs_hj' && value > 5) {
                value = 5;
            } */
            if (target) {
                target[column] = value;
                // console.log('target[column]',target[column])
                this.dataSource = newData;
                // console.log('input',this.dataSource)
            }
        },
        edit(key) {
            const newData = [...this.dataSource];
            const target = newData.filter(item => key === item.key)[0];
            this.editingKey = key;
            if (target) {
                target.editable = true;
                this.dataSource = newData;
            }
        },
        save(key, record) {
            if (record.sfzs == '主审') {
                if (!record.fs_pingshenyj) {
                    this.$message.warning('请填写评审意见');
                    return;
                }
            }
            const newData = [...this.dataSource];
            const newCacheData = [...this.cacheData];
            const target = newData.filter(item => key === item.key)[0];
            const targetCache = newCacheData.filter(item => key === item.key)[0];
            if (target && targetCache) {
                delete target.editable;
                this.dataSource = newData;
                Object.assign(targetCache, target);
                this.cacheData = newCacheData;
            }
            this.editingKey = '';
            let formData = {
                // 成果陈述
                fsXmcs: record.fs_xmcs,
                // 专家提问及应答
                fsZjtw: record.fs_zjtw,
                // 创新程度
                fsCx: record.fs_cx,
                // 技术水平
                fsJs: record.fs_js,
                // 先进水平
                fsXj: record.fs_xj,
                // 经济效益
                fsJj: record.fs_jj,
                // 社会效益
                fsSh: record.fs_sh,
                // 促进行业经济发展
                fsCj: record.fs_cj,
                // 提升管理水平
                fsTs: record.fs_ts,
                // 知识产权
                fsZs: record.fs_zs,
                // 获奖情况
                // fsHj: record.fs_hj,
                // 评审意见
                fsPingshenyj: record.fs_pingshenyj,
                // 是否回避
                fsSfhb: record.fs_sfhb,
                // 总分
                fsZongfen: record.fs_xjx,
                cxjCxjId: record.cxj_cxj_id,
                id: record.id,
                jscsZt: record.fs_zhuangtai
            }
            console.log('技术复审',formData)
            cxjfsSavePfBzBz(formData).then(res=>{
                if (res.code == 200) {
                    this.$message.success(res.message);
                    this.loadData();
                    this.getjsfsPfTjZj();
                } else {
                    this.$message.warning(res.message);
                    this.loadData();
                    this.getjsfsPfTjZj();
                }
            })
        },
        cancel(key) {
            const newData = [...this.dataSource];
            const target = newData.filter(item => key === item.key)[0];
            this.editingKey = '';
            if (target) {
                Object.assign(target, this.cacheData.filter(item => key === item.key)[0]);
                delete target.editable;
                this.dataSource = newData;
            }
            this.loadData();
        },
        /* 对行内进行修改结束 */

        /* 获取列表固定格式开始 */
        getQueryField() {
            //TODO 字段权限控制
            var str = "id,";
            this.columns.forEach(function (value) {
                str += "," + value.dataIndex;
            });
            return str;
        },
        // 获取分组项目
        loadData(arg) {
            if (arg === 1) {
                this.ipagination.current = 1;
            }
            this.loading = true;
            let user = Vue.ls.get(USER_INFO);

            // console.log('专家信息',user)
            let params = Object.assign(this.queryParam, this.isorter, this.filters)
            params.field = this.getQueryField();
            params.pageNo = this.ipagination.current;
            params.pageSize = this.ipagination.pageSize;
            params.fzid = this.fzid;
            if (this.dbsj == 'all') {
                params.dbsj = ''
            } else {
                params.dbsj = this.dbsj;
            }
            cxjfsGetFzxmListByFzidBz(qs.stringify(params)).then(res=>{
                if (res.success) {
                    this.dataSource = res.result.records || res.result;
                    this.dataSource.map((item,index)=>{
                        item.key = index;
                        item.total_score = item.fs_zongfen;
                        if (!item.fs_sfhb){
                            item.fs_sfhb = "N";
                        }
                    })
                    this.cacheData = this.dataSource;
                    if (res.result.total) {
                        this.ipagination.total = res.result.total;
                    } else {
                        this.ipagination.total = 0;
                    }
                }
                if (res.code === 510) {
                    this.$message.warning(res.message)
                }
                this.loading = false;
            })
        },
        onSelectChange(selectedRowKeys, selectionRows) {
            this.selectedRowKeys = selectedRowKeys;
            this.selectionRows = selectionRows;
        },
        onClearSelected() {
            this.selectedRowKeys = [];
            this.selectionRows = [];
        },
        modalFormOk() {
            // 新增/修改 成功时，重载列表
            this.loadData();
            //清空列表选中
            this.onClearSelected()
        },
        handleTableChange(pagination, filters, sorter) {
            //分页、排序、筛选变化时触发
            //TODO 筛选
            if (Object.keys(sorter).length > 0) {
                if (this.editingKey) {
                } else {
                    this.loadData();
                }
                this.isorter.column = sorter.field;
                this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
            } else {
                this.loadData();
            }
            this.ipagination = pagination;
            // this.loadData();
            // if (Object.keys(sorter).length > 0) {
            //     this.isorter.column = sorter.field;
            //     this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
            // }
            // this.ipagination = pagination;
            // this.loadData();
        },
        /* 获取列表固定格式结束 */





        initDictConfig(){},
        getSuperFieldList(){
            let fieldList=[];
            fieldList.push({type:'string',value:'sysZjId',text:'专家ID',dictCode:''})
            fieldList.push({type:'string',value:'cxjCxjId',text:'成果ID',dictCode:''})
            fieldList.push({type:'double',value:'jscsCxx',text:'技术创新性',dictCode:''})
            fieldList.push({type:'double',value:'jscsXjx',text:'技术先进性',dictCode:''})
            fieldList.push({type:'double',value:'jscsSsxg',text:'实用化程度',dictCode:''})
            fieldList.push({type:'double',value:'jscsJjxy',text:'经济效益',dictCode:''})
            fieldList.push({type:'double',value:'jscsTgjz',text:'推动作用',dictCode:''})
            fieldList.push({type:'string',value:'jscsPingjiayj',text:'评审意见',dictCode:''})
            fieldList.push({type:'double',value:'jscsZongfen',text:'总分',dictCode:''})
            fieldList.push({type:'string',value:'jscsZt',text:'评分状态',dictCode:''})
            fieldList.push({type:'string',value:'shijian',text:'年度',dictCode:''})
            fieldList.push({type:'string',value:'bz1',text:'备注1',dictCode:''})
            fieldList.push({type:'string',value:'bz2',text:'备注2',dictCode:''})
            fieldList.push({type:'string',value:'bz3',text:'备注3',dictCode:''})
            fieldList.push({type:'switch',value:'isValid',text:'是否有效'})
            this.superFieldList = fieldList
        }
    }
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
/deep/ * {
  font-size: 14px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
/deep/.ant-table-tbody > tr > td {
  word-break: break-all;
  white-space: normal;
  word-wrap:break-word;
  font-size:14px;
  padding:6px 3px!important;
}
/deep/.ant-table-tbody > tr > td > div {
  font-size: 14px;
}

/deep/.ant-table-thead > tr > th {
  word-break: break-all;
  white-space: normal;
  word-wrap:break-word;
  text-align: center;
  font-size:14px;
  padding:5px 3px!important;
}
.editable-row-operations a {
  margin-right: 8px;
}
.tjdata {
  // margin-top: 20px;
  span {
    margin-right:20px;
    line-height: 30px;
    font-size: 16px;
  }
}
.count {
  color: #ee9900;
  font-weight: 700;
  font-size: 16px;
}
/deep/.ant-table-tbody > tr > td:nth-child(15) {
  color: #ee9900!important;
  font-weight: 700;
  font-size: 16px;
}
.editable-row-operations a {
  margin: 0px 2px;
}
  .table-page-search-wrapper .anty-form-btn .ant-form-item {
    margin-bottom: 10px;
  }

// 用于解决表格气泡框字数过多时，不居中显示的问题
.sl-span{
  width: auto;
  max-width: 100%;
  display: inline-block; //会根据内容适配宽度
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: top; //添加此属性不会引起错位
}
</style>